import * as fs from 'fs-extra';
import { Swagger } from '../interface';

interface Params {
  outDir: string; 
  fileName: string;
}

export function lockGenerate(data: Partial<Swagger>, params: Params) {
  const { outDir, fileName } = params;

  return new Promise((resolve, reject) => {
    fs.outputJson(`${outDir}/${fileName}-lock.json`, data, { spaces: 2 }, err => {
      if (err) {
        reject(err);
      }
      console.log(`Generate ${fileName}-lock.json success!`);
      resolve();
    });
  })
};
